package com.lzy.liujing.restaurant.dao;

import com.lzy.liujing.restaurant.entity.Desk;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface DeskDao {
    @Select("select * from r_desk")
    List<Desk> selectAll();

    @Select("<script> SELECT * from r_desk" +
            "<where>"+
            "<if test='idleStatus != null'>and idle_status = #{idleStatus}</if> "+
            " <if test='deskCode != null'>and desk_code = #{deskCode}</if> "+
            " <if test='peopleCount != null'>and people_count = #{peopleCount} </if> " +
            "</where>"+
            "</script>")
    List<Desk> findPage(Desk query);

    @Delete("delete from r_desk where desk_id =#{deskId}")
    int delete(Integer id);

    @Insert("insert into r_desk (desk_code, people_count,idle_status)values(#{deskCode},#{peopleCount},#{idleStatus} )")
    int insert(Desk brand);

    @Update("update r_desk set desk_code = #{deskCode}, people_count = #{peopleCount}," +
            " idle_status = #{idleStatus}  where desk_id = #{deskId}")
    int update(Desk brand);

    @Select("SELECT * FROM r_desk WHERE desk_id = #{deskId}")
    Desk getById(Integer id);

    @Select("select * from r_desk where desk_code = #{deskCode}")
    Desk selectByCode(String id);

    @Update("UPDATE r_desk SET idle_status = #{idleStatus} WHERE desk_code = #{deskCode}")
    int updateStatusByOrderCode(String deskCode,String idleStatus);
}
